<?php
	
    include __DIR__ . "/../vendor/cloudinary/src/Cloudinary.php";

    include __DIR__ . "/../vendor/cloudinary/src/Uploader.php";

    include __DIR__ . "/../vendor/cloudinary/src/Api.php";

 	
 	Cloudinary::config(array( 
      "cloud_name" => "flss", 
      "api_key" => "843797854226639", 
      "api_secret" => "GYZR50smlbKnQ3V0SVnO-3FEXJ4" 
    ));

 	function uploadCover($employer_id,$from,$height,$width)
	{

		$version =  \Cloudinary\Uploader::upload($from,
		    array(
		       "public_id" => 'cover_'.$employer_id,
		       "height" => $height,
		       "width" => $width,
		       "invalidate" => true
		    ))['version'];

		$version = $version.'/cover_'.$employer_id.'.jpg';

		$phql = "UPDATE employer set cover = '{$version}' where employer_id = {$employer_id}";

		$data =  mysql_query($phql);
		$result = "false";
		if($data)
		{
			$result = "true";
		}
		else
		{
			$result = "false";
		}
		return $result;
	}

 	function uploadLogo($employer_id,$from,$height,$width)
	{

		$version =  \Cloudinary\Uploader::upload($from,
		    array(
		       "public_id" => 'logo_'.$employer_id,
		       "height" => $height,
		       "width" => $width,
		       "invalidate" => true
		    ))['version'];

		$version = $version.'/logo_'.$employer_id.'.jpg';

		$phql = "UPDATE employer set logo = '{$version}' where employer_id = {$employer_id}";

		$data =  mysql_query($phql);
		$result = "false";
		if($data)
		{
			$result = "true";
		}
		else
		{
			$result = "false";
		}
		return $result;
	}

	function uploadphoto($applicant_id,$from,$height,$width){
		$version = \Cloudinary\Uploader::upload($from,
			array(
				"public_id" => 'photo_'.$applicant_id,
				"height" => $height,
				"width" => $width,
				"invalidate" => true
				))['version'];

		$version = $version.'/photo_'.$applicant_id.'.jpg';

		$phql = "UPDATE applicant set photo = '{$version}' where applicant_id = {$applicant_id}";

		$data =  mysql_query($phql);
		$result = "false";
		if($data)
		{
			$result = "true";
		}
		else
		{
			$result = "false";
			$result = mysql_error();
		}
		return $result;
	}

	
?>